
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>http模块 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="log.html" />
    
    
    <link rel="prev" href="db.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    快速开始
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../start/param.html">
            
                <a href="../start/param.html">
            
                    
                    参数获取
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../start/crud.html">
            
                <a href="../start/crud.html">
            
                    
                    增删改查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../start/table.html">
            
                <a href="../start/table.html">
            
                    
                    单表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../start/page.html">
            
                <a href="../start/page.html">
            
                    
                    分页查询
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    核心模块
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="db.html">
            
                <a href="db.html">
            
                    
                    db模块
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="http.html">
            
                <a href="http.html">
            
                    
                    http模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="log.html">
            
                <a href="log.html">
            
                    
                    log模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="env.html">
            
                <a href="env.html">
            
                    
                    env模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    特殊函数
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../function/agg.html">
            
                <a href="../function/agg.html">
            
                    
                    聚合函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../function/date.html">
            
                <a href="../function/date.html">
            
                    
                    日期函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../function/string.html">
            
                <a href="../function/string.html">
            
                    
                    字符串函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../function/array.html">
            
                <a href="../function/array.html">
            
                    
                    数组函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../function/math.html">
            
                <a href="../function/math.html">
            
                    
                    数学函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../function/other.html">
            
                <a href="../function/other.html">
            
                    
                    其他函数
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    对象方法
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../object/object.html">
            
                <a href="../object/object.html">
            
                    
                    Object对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../object/number.html">
            
                <a href="../object/number.html">
            
                    
                    Number对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../object/list.html">
            
                <a href="../object/list.html">
            
                    
                    数组&集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../object/date.html">
            
                <a href="../object/date.html">
            
                    
                    Date对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../object/class.html">
            
                <a href="../object/class.html">
            
                    
                    Class对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../object/pattern.html">
            
                <a href="../object/pattern.html">
            
                    
                    Patter对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    脚本语法
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../syntax/keyword.html">
            
                <a href="../syntax/keyword.html">
            
                    
                    关键字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../syntax/type.html">
            
                <a href="../syntax/type.html">
            
                    
                    类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../syntax/yunsuan.html">
            
                <a href="../syntax/yunsuan.html">
            
                    
                    运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../syntax/yiyuan.html">
            
                <a href="../syntax/yiyuan.html">
            
                    
                    运算符示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../syntax/for.html">
            
                <a href="../syntax/for.html">
            
                    
                    for循环
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../syntax/import.html">
            
                <a href="../syntax/import.html">
            
                    
                    导入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../syntax/async.html">
            
                <a href="../syntax/async.html">
            
                    
                    异步
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >http模块</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h4 id="&#x6A21;&#x5757;&#x8BF4;&#x660E;">&#x6A21;&#x5757;&#x8BF4;&#x660E;</h4>
<p><code>http</code>&#x6A21;&#x5757;&#x662F;&#x57FA;&#x4E8E;<code>RestTemplate</code>&#x5C01;&#x88C5;&#x800C;&#x6765;&#xFF0C;&#x76EE;&#x524D;&#x53EA;&#x505A;&#x4E86;&#x5C11;&#x91CF;&#x7684;&#x5C01;&#x88C5;&#x3002; &#x5BF9;&#x4E8E;&#x4E00;&#x4E9B;&#x901A;&#x7528;&#x7684;&#x914D;&#x7F6E;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;<code>RestTemplate</code>&#x6765;&#x5B9E;&#x73B0;</p>
<pre><code class="lang-java"><span class="hljs-meta">@Bean</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> HttpModule <span class="hljs-title">magicHttpModule</span><span class="hljs-params">()</span> </span>{
    RestTemplate template = <span class="hljs-keyword">new</span> RestTemplate();
    <span class="hljs-comment">// &#x5BF9;RestTemplate&#x8FDB;&#x884C;&#x914D;&#x7F6E;.</span>
    <span class="hljs-comment">// your code</span>
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> HttpModule(template);
}
</code></pre>
<h4 id="&#x5F15;&#x7528;&#x6A21;&#x5757;">&#x5F15;&#x7528;&#x6A21;&#x5757;</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
</code></pre>
<h4 id="connect">connect</h4>
<ul>
<li>&#x5165;&#x53C2;&#xFF1A;<code>url</code>:<code>string</code></li>
<li>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;<code>HttpModule</code></li>
<li>&#x51FD;&#x6570;&#x8BF4;&#x660E;&#xFF1A;&#x521B;&#x5EFA;&#x65B0;&#x7684;http&#x8BF7;&#x6C42;&#x5BF9;&#x8C61;</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
http.connect(<span class="hljs-string">&quot;http://localhost:9999/sql/select&quot;</span>)
</code></pre>
<h4 id="&#x8BBE;&#x7F6E;&#x53C2;&#x6570;">&#x8BBE;&#x7F6E;&#x53C2;&#x6570;</h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
http.param(<span class="hljs-string">&apos;url_param1&apos;</span>,<span class="hljs-string">&apos;url_param_value1&apos;</span>) <span class="hljs-comment">// &#x8BBE;&#x7F6E;URL&#x53C2;&#x6570;</span>
    .param({    <span class="hljs-comment">// &#x6279;&#x91CF;&#x8BBE;&#x7F6E;URL&#x53C2;&#x6570;</span>
        url_param_2 : <span class="hljs-number">2</span>,
        url_param_3 : <span class="hljs-number">3</span>,
    })
    .data(<span class="hljs-string">&apos;form_param1&apos;</span>,<span class="hljs-string">&apos;form_param_value1&apos;</span>) <span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x8868;&#x5355;&#x53C2;&#x6570;</span>
    .data({    <span class="hljs-comment">// &#x6279;&#x91CF;&#x8BBE;&#x7F6E;&#x8868;&#x5355;&#x53C2;&#x6570;</span>
        form_param_2 : <span class="hljs-number">2</span>,
        form_param_3 : <span class="hljs-number">3</span>,
    })
    .header(<span class="hljs-string">&apos;header_param1&apos;</span>,<span class="hljs-string">&apos;header_param_value1&apos;</span>) <span class="hljs-comment">// &#x8BBE;&#x7F6E;header&#x53C2;&#x6570;</span>
    .header({    <span class="hljs-comment">// &#x6279;&#x91CF;&#x8BBE;&#x7F6E;header&#x53C2;&#x6570;</span>
        header_param_2 : <span class="hljs-number">2</span>,
        header_param_3 : <span class="hljs-number">3</span>,
    })
</code></pre>
<h4 id="body">body</h4>
<ul>
<li>&#x5165;&#x53C2;&#xFF1A;<code>body</code>:<code>Object</code></li>
<li>&#x51FD;&#x6570;&#x8BF4;&#x660E;&#xFF1A;&#x83B7;&#x53D6;&#x8BF7;&#x6C42;Body</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
http.connect(<span class="hljs-string">&apos;..&apos;</span>).body({
    id: <span class="hljs-number">1</span>,
    name: <span class="hljs-string">&apos;magic-api&apos;</span>
});
</code></pre>
<h4 id="entity">entity</h4>
<ul>
<li>&#x5165;&#x53C2;: <code>entity</code>: <code>HttpEntity</code></li>
<li>&#x51FD;&#x6570;&#x8BF4;&#x660E;&#xFF1A;&#x81EA;&#x5B9A;&#x4E49;<code>HttpEntity</code></li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
http.connect(<span class="hljs-string">&apos;..&apos;</span>).entity(entity)
</code></pre>
<h4 id="contenttype">contentType</h4>
<ul>
<li>&#x5165;&#x53C2;: <code>contentType</code>: <code>String</code>&#x6216;<code>MediaType</code></li>
<li>&#x51FD;&#x6570;&#x8BF4;&#x660E;&#xFF1A;&#x5B9A;&#x4E49;&#x8BF7;&#x6C42;&#x5185;&#x5BB9;&#x7C7B;&#x578B;</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
http.connect(<span class="hljs-string">&apos;..&apos;</span>).contentType(<span class="hljs-string">&apos;application/json&apos;</span>)
</code></pre>
<h4 id="execute">execute</h4>
<ul>
<li>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;<code>ResponseEntity</code></li>
<li>&#x51FD;&#x6570;&#x8BF4;&#x660E;&#xFF1A;&#x6267;&#x884C;&#x5BF9;&#x5E94;&#x7684;&#x8BF7;&#x6C42;&#xFF0C;post&#x4F1A;&#x81EA;&#x52A8;&#x8BBE;&#x7F6E;&#x4E3A;POST&#x8BF7;&#x6C42;&#xFF0C;&#x5176;&#x5B83;&#x540C;&#x7406;</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> http;
<span class="hljs-keyword">return</span> http.connect(<span class="hljs-string">&apos;http://localhost:9999/sql/select&apos;</span>).post().getBody()
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="db.html" class="navigation navigation-prev " aria-label="Previous page: db模块">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="log.html" class="navigation navigation-next " aria-label="Next page: log模块">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"http模块","level":"1.3.2","depth":2,"next":{"title":"log模块","level":"1.3.3","depth":2,"path":"module/log.md","ref":"module/log.md","articles":[]},"previous":{"title":"db模块","level":"1.3.1","depth":2,"path":"module/db.md","ref":"module/db.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"module/http.md","mtime":"2023-12-28T04:58:59.330Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-01-02T08:17:25.965Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

